<?php
// +----------------------------------------------------------------------
// | 添加添加友情链接信息模型
// +----------------------------------------------------------------------
// | @link
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: LinksModel.class.php 47 2011-02-25 09:21:36Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class LinksModel extends Model {

	public $_validate	=	array(
		array('link_name','require','{%link_name_require}'),
		array('link_url','url','{%link_url_url}'),
		array('link_sort','require','{%link_sort_require}'),
		array('link_name','','{%link_name_unique}',0,'unique',1),
	);

	public $_auto		=	array(
		array('link_status','1',1),
		array('link_visible','1',1),
		array('link_addtime','time',3,'function'),
		array('link_url','fillLinkUrl',3,'callback'),
	);
	
	/* 如果友情链接的链接地址没有http://，补上 */
	protected function fillLinkUrl() {
		if (strpos($_POST['link_url'], 'http://') === false && strpos($_POST['link_url'], 'https://') === false) {
            $link_url = 'http://' . trim($_POST['link_url']);
        } else {
            $link_url = trim($_POST['link_url']);
        }
        return $link_url;
	}
		
}

?>